package com.rtx.wms.std.job.so;

import java.util.List;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import com.rtx.api.annotation.RtxJobAnnotation;
import com.rtx.api.quartz.job.BaseJob;
import com.rtx.edi.model.api.bo.ApiMappingInfoBo;
import com.rtx.edi.platform.baseinfo.service.PlApiService;
import com.rtx.wms.std.common.bean.WmsConstant;
import com.rtx.wms.std.common.service.CommonService;
import com.rtx.wms.std.handler.so.upload.OrdersReturnHandler;

@Component
@DisallowConcurrentExecution
@RtxJobAnnotation(jobName = "OrdersReturnJob",description = "出库单回传",cron = "0/30 * * * * ?")
public class OrdersReturnJob implements BaseJob {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private OrdersReturnHandler ordersReturnHandler;

    @Autowired
    private CommonService commonService;
    
    @Autowired
    PlApiService plApiService;
    

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
    	ApiMappingInfoBo bo = null;
    	try {
    		JobDataMap dataMap = context.getJobDetail().getJobDataMap();
    		
    		String mappingCode = dataMap.get("apiMappingCode")+"";
    		
    		bo = plApiService.getApiMappingInfo(mappingCode);
		} catch (Exception e) {
			logger.error("",e);
		}
    	
    	try {
            ordersReturnHandler.handlerOrdersReturn("ris_edi",bo);
        } catch (Exception e) {
            logger.error("出库单回传异常",e);
        }
    }
}
